<?php

class jwGalleryActions extends sfActions
{
    public function executeGetImage()
    {
      header('Content-type: image/png');
      $id = $this->getRequestParameter( 'id' );
      $thumb = $this->getRequestParameter( 'thumb' );
      
      $img = jwGalleryPicturePeer::retrieveByPK( $id );
      $path = $img->getjwGallery()->getPath();
      
      $full_path = sfConfig::get( 'sf_root_dir').DIRECTORY_SEPARATOR.'galleries'.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR;
      if ( $thumb )
        $full_path .= "thumbs".DIRECTORY_SEPARATOR.$thumb.DIRECTORY_SEPARATOR;
      
      if ( file_exists( $full_path.$img->getFileName() ) )
      {
        $a = new gdImage( $full_path.$img->getFileName() );
        if ( !$thumb )
            $a->setColor( "#FFFFFF50" )->writeTTFText( sfConfig::get( 'app_watermark' ), 14, 45, 'right', 'bottom' )->show();
        else
            $a->show();
      }
      else
        $this->redirect404();
      
      return sfView::NONE;
    }
}

?>